package com.zzy.config;


import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

/**
 * 消费者监听topic为 my-replication-topic 的消息
 */
@Component
public class ConsumerController {

   // static String topic_ = "my-replication-topic";
    @KafkaListener(topics = "my-replication-topic")
    public void onMessage(ConsumerRecord<?, ?> record){
        //消费后打印出来
        byte[] bytes = (byte[]) record.value();
        System.out.println("消费了："+record.topic()+"-"+record.partition()+"-"+   new String(bytes) );
    }

}
